// pages/film/film.js
const app= getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
      list:[],
      actors:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options);
    this.gethome(options)
  },
  gethome(options=5687){
    app.get('film/detail',options).then(res => {
      let detail =res.data;
      detail.premiereAt = this.formatDate(detail.premiereAt);
      this.setData({
        detail,
        list:res.data,
        actors:res.data.actors
      },()=>{
        wx.hideLoading()
      })
    })
  },
  formatDate(time){
    let date =new Date(time);
    let y=date.getFullYear();
    let m=date.getMonth()+1;
    let d=date.getDay();
    m=m<10?'0'+m:m;
    d=d<10?'0'+d:d;
    return  `${y}-${m}-${d}`;
  },
})